
import 'dart:html';

import 'package:snooperlang/src/snooperParser.dart';

class AstVisitor extends AbstractResultVisitor{
  @override
  Object? unimplementedVisitor(String s) {

    return null;
  }
  @override
  Object? visitASTNodeToken(ASTNodeToken n, [Object? o]){

  }

  @override
  Object? visitSnooperProg(SnooperProg n, [Object? o]) {
    visitNodeWithChildRen(n,o);
  }

  @override
  Object? visitSnooperSegmentItemList(SnooperSegmentItemList n, [Object? o]){
      visitNodeWithChildRen(n,o);
  }
  @override
  Object? visitReturnSeg(ReturnStmt n, [Object? o]){
    var exp = n.getExpressionOpt();
       if(exp != null){
         return visit(n,o);
       }
       return null;
  }
  @override
  Object? visitFunctionDecl(FunctionDecl n, [Object? o]){
       var body = n.getBlockOpt();
       if(body != null){
         return visit(body,o);
       }
       return null;
  }
  @override
  Object? visitStatementList_StatementList(StatementList_StatementList n, [Object? o]){
    Object? ret;
    for (var i = 0; i < n.size(); i++){
      var node = n.getStatementAt(i);
      ret= visit(node,o);
    }
    return ret;
  }
  @override
  Object? visitStatementList(StatementList n, [Object? o]){
    Object? ret;
    for (var i = 0; i < n.size(); i++){
      var node = n.getStatementAt(i);
      ret= visit(node,o);
    }
    return ret;
  }
  @override
  Object? visitIfSeg(IfSeg n, [Object? o]){
      visit(n.getExpression(),o);
      var opt = n.getBlockOpt();
      if(opt != null){
        visit(opt,o);
      }
  }

  @override
  Object? visitIfThenStatement(IfThenStatement n, [Object? o]){
      visit(n.getIfSeg(),o);
      var elseIfSegs = n.getElseIfStatementOpt();
      if(elseIfSegs != null){
        visit(elseIfSegs,o);
      }
  }

  @override
  Object? visitElseSeg(ElseSeg n, [Object? o]){
    var opt = n.getBlockOpt();
    if(opt != null){
      visit(opt,o);
    }
  }

  @override
  Object? visitIfThenElseStatement(IfThenElseStatement n, [Object? o]){
    visit(n.getIfSeg(),o);

    var elseIfSegs = n.getElseIfStatementOpt();
    if(elseIfSegs != null){
      visit(elseIfSegs,o);
    }

    visit(n.getElseSeg(),o);
  }
  @override
  Object? visitElseIfStatementItemList(ElseIfStatementItemList n, [Object? o]){
    Object? ret;
    for (var i = 0; i < n.size(); i++){
      var node = n.getElseIfStatementItemAt(i);
      ret= visitElseIfStatementItem(node,o);
    }
    return ret;
  }

  Object? visitElseIfStatementItem(ElseIfStatementItem n, [Object? o]){

        visit(n.getExpression(),o);
        var opt = n.getBlockOpt();
        if(opt != null){
          visit(opt,o);
        }
  }

  Object? visitVariable(Variable n, [Object? o]){
    return  null;
  }

  Object? visitBadVariable(BadVariable n, [Object? o]){
    return  null;
  }

  Object? visitLetOpt(LetOpt n, [Object? o]){
    return  null;
  }

  Object? visitVariableStmt(VariableStmt n, [Object? o]){
       return visit(n.getVariableDecl(),o);
  }

  Object? visitPrimaryAssignmentStmt(PrimaryAssignmentStmt n, [Object? o]){
      return visit(n.getExpression(),o);
  }

  Object? visitArrayAccesOnLeftSide(ArrayAccesOnLeftSide n, [Object? o]){
    return visit(n.getExpression(),o);
  }

  Object? visitArrayAccessAssignmentStmt(ArrayAccessAssignmentStmt n, [Object? o]){
    visit(n.getArrayAccesOnLeftSide(),o);
    return visit(n.getExpression(),o);
  }

  Object? visitKeywordAssignmentStmt(KeywordAssignmentStmt n, [Object? o]){
    visit(n.getsw(),o);
    return visit(n.getExpression(),o);

  }

  Object? visitBadAssignment(BadAssignment n, [Object? o]){
    return null;
  }

  Object? visitDoLoopStmt(DoLoopStmt n, [Object? o]){
     var opt = n.getExpressionOpt();
     if(opt != null){
       visit(opt,o);
     }
     var blockOpt = n.getBlockOpt();
     if(blockOpt != null){
       visit(blockOpt,o);
     }
     return null;
  }

  Object? visitStepStmOpt(StepStmOpt n, [Object? o]){
       visit(n.getExpression(),o);
  }

  Object? visitForStmt(ForStmt n, [Object? o]){
      visit(n.getVariableDecl(),o);
      visit(n.getPrimary(),o);
      var opt = n.getStepStmOpt();
      if(opt != null) {
        visit(opt,o);
      }
      var blockOpt = n.getBlockOpt();
      if(blockOpt != null){
        visit(blockOpt,o);
      }

  }

  Object? visitNextSeg(NextSeg n, [Object? o]){

  }

  Object? visitHforStmt(HforStmt n, [Object? o]){
      visit(n.getVariableDecl(),o);
      visit(n.getPrimary(),o);
      var opt = n.getStepStmOpt();
      if(opt != null) {
        visit(opt,o);
      }
      var blockOpt = n.getBlockOpt();
      if(blockOpt != null){
        visit(blockOpt,o);
      }
  }

  Object? visitHnexSeg(HnexSeg n, [Object? o]){

  }

  Object? visitNumberLiteral(NumberLiteral n, [Object? o]){
    return n.value;
  }

  Object? visitStringLiteral(StringLiteral n, [Object? o]){
      return n.value;
  }

  Object? visitSimpleName(SimpleName n, [Object? o]){

  }

  Object? visitSimpleNameList(SimpleNameList n, [Object? o]){
       for(var i = 0 ; i < n.size(); ++i){
         visit(n.getElementAt(i),o);
       }
  }

  Object? visitArrayAccess(ArrayAccess n, [Object? o]){
       visit(n.getVariable(),o);
       visit(n.getExpression(),o);
  }

  Object? visitHexMacroPrimary(HexMacroPrimary n, [Object? o]){
    visitNodeWithChildRen(n,o);
  }

  Object? visitApduDataWith3Lc(ApduDataWith3Lc n, [Object? o]){
    visitNodeWithChildRen(n,o);
  }

  Object? visitApduDataWith2Lc(ApduDataWith2Lc n, [Object? o]){
    visitNodeWithChildRen(n,o);
  }

  Object? visitApduDataWith4Lc(ApduDataWith4Lc n, [Object? o]){
    visitNodeWithChildRen(n,o);
  }

  Object? visitApduDataWithoutLc(ApduDataWithoutLc n, [Object? o]){
    visitNodeWithChildRen(n,o);
  }

  Object? visitApduDataList(ApduDataList n, [Object? o]){
    visitNodeWithChildRen(n,o);
  }

  Object? visitPostIncrementExpression(PostIncrementExpression n, [Object? o]){
    visitNodeWithChildRen(n,o);
  }

  Object? visitPostDecrementExpression(PostDecrementExpression n, [Object? o]){

  }

  Object? visitPreIncrementExpression(PreIncrementExpression n, [Object? o]){
    visitNodeWithChildRen(n,o);
  }

  Object? visitPreDecrementExpression(PreDecrementExpression n, [Object? o]){
    visitNodeWithChildRen(n,o);
  }

  Object? visitUnaryExpNotPlusMinus_Xor(UnaryExpNotPlusMinus_Xor n, [Object? o]){

  }

  Object? visitUnaryExpNotPlusMinus_Not(UnaryExpNotPlusMinus_Not n, [Object? o]){
    visitNodeWithChildRen(n,o);
  }

  Object? visitMultiplicativeExp_Divide(MultiplicativeExp_Divide n, [Object? o]){
    visitNodeWithChildRen(n,o);
  }

  Object? visitMultiplicativeExp_Multiply(MultiplicativeExp_Multiply n, [Object? o]){
    visitNodeWithChildRen(n,o);
  }

  Object? visitMultiplicativeExp_Remainder(MultiplicativeExp_Remainder n, [Object? o]){
    visitNodeWithChildRen(n,o);
  }

  Object? visitAdditiveExp_Plus(AdditiveExp_Plus n, [Object? o]){
    visitNodeWithChildRen(n,o);
  }

  Object? visitAdditiveExp_Minus(AdditiveExp_Minus n, [Object? o]){
    visitNodeWithChildRen(n,o);
  }

  Object? visitShiftExp_Left(ShiftExp_Left n, [Object? o]){
    visitNodeWithChildRen(n,o);
  }

  Object? visitShiftExp_Right(ShiftExp_Right n, [Object? o]){
    visitNodeWithChildRen(n,o);
  }

  Object? visitRelationalExp_Less(RelationalExp_Less n, [Object? o]){
    visitNodeWithChildRen(n,o);
  }

  Object? visitRelationalExp_Greater(RelationalExp_Greater n, [Object? o]){
    visitNodeWithChildRen(n,o);
  }

  Object? visitRelationalExp_LessEqual(RelationalExp_LessEqual n, [Object? o]){
    visitNodeWithChildRen(n,o);
  }

  Object? visitRelationalExp_GreaterEqual(RelationalExp_GreaterEqual n, [Object? o]){
    visitNodeWithChildRen(n,o);
  }

  Object? visitEqualityExpr_EqualEqual(EqualityExpr_EqualEqual n, [Object? o]){
    visit(n.getEqualityExpression(),o);
    visit(n.getRelationalExpression(),o);
  }
  void visitNodeWithChildRen(ASTNode n,[Object? o]){
    var children = n.getChildren();
    for(var i = 0 ; i < children.size(); ++i){
      ASTNode child = children.get(i);
      visit(child,o);
    }
  }
  Object? visitEqualityExpr_NotEqual(EqualityExpr_NotEqual n, [Object? o]){
    visit(n.getEqualityExpression(),o);
    visit(n.getRelationalExpression(),o);
  }

  Object? visitAndExpression(AndExpression n, [Object? o]){
    visit(n.getAndExpression(),o);
    visit(n.getEqualityExpression(),o);
  }

  Object? visitExclusiveOrExpression(ExclusiveOrExpression n, [Object? o]){
    visit(n.getExclusiveOrExpression(),o);
    visit(n.getAndExpression(),o);
  }

  Object? visitInclusiveOrExpression(InclusiveOrExpression n, [Object? o]){
    visit(n.getInclusiveOrExpression(),o);
    visit(n.getExclusiveOrExpression(),o);
  }

  Object? visitConditionalAndExpression(ConditionalAndExpression n, [Object? o]){
    visit(n.getConditionalAndExpression(),o);
    visit(n.getInclusiveOrExpression(),o);
  }

  Object? visitConditionalOrExpression(ConditionalOrExpression n, [Object? o]){

        visit(n.getConditionalOrExpression(),o);
        visit(n.getConditionalAndExpression(),o);
  }

  Object? visitExpressionStmt(ExpressionStmt n, [Object? o]){
    return visit(n.getExpression(),o);
  }

  Object? visitVariableAndSW(VariableAndSW n, [Object? o]){

  }

  Object? visitExpressionList(ExpressionList n, [Object? o]){
      for(var i = 0 ; i < n.size(); ++i){
        visit(n.getElementAt(i),o);
      }
  }

  Object? visitCallOpt(CallOpt n, [Object? o]){

  }

  Object? visitFunctionCall(FunctionCall n, [Object? o]){
    var opt = n.getArgumentListOpt();
    if(opt != null){
      visit(opt,o);
    }
  }

  Object? visitExitForStatement(ExitForStatement n, [Object? o]){

  }

  Object? visitExitHforStatement(ExitHforStatement n, [Object? o]){

  }

  Object? visitLoadScriptStmt(LoadScriptStmt n, [Object? o]){
    visit(n.getSTRING_LITERAL(),o);
  }

  Object? visitSimpleOption_timer_begin(SimpleOption_timer_begin n, [Object? o]){

  }

  Object? visitSimpleOption_timer_end(SimpleOption_timer_end n, [Object? o]){

  }

  Object? visitSimpleOption_pause(SimpleOption_pause n, [Object? o]){

  }

  Object? visitSimpleOption_file(SimpleOption_file n, [Object? o]){

  }

  Object? visitSimpleOption_line(SimpleOption_line n, [Object? o]){

  }

  Object? visitSimpleOption_clear_fifo(SimpleOption_clear_fifo n, [Object? o]){

  }

  Object? visitSimpleOption_beep(SimpleOption_beep n, [Object? o]){

  }

  Object? visitSimpleOption_eject(SimpleOption_eject n, [Object? o]){

  }

  Object? visitSimpleOption_insert(SimpleOption_insert n, [Object? o]){

  }

  Object? visitSimpleOption_split(SimpleOption_split n, [Object? o]){

  }

  Object? visitSimpleOption_end(SimpleOption_end n, [Object? o]){

  }

  Object? visitSimpleOption_clear(SimpleOption_clear n, [Object? o]){

  }

  Object? visitKeyWordWithoutParameterStmt(KeyWordWithoutParameterStmt n, [Object? o]){
    visit(n.getSimpleOption(),o);
  }

  Object? visitSleepStmt(SleepStmt n, [Object? o]){
    visit(n.getExpression(),o);
  }

  Object? visitSetStmt_Identifier(SetStmt_Identifier n, [Object? o]){

  }

  Object? visitSetStmt_MacroName(SetStmt_MacroName n, [Object? o]){
    visit(n.getVariable(),o);
  }

  Object? visitPrintStmt_Message(PrintStmt_Message n, [Object? o]){
    var opt = n.getExpressionOpt();
    if(opt != null){
      visit(opt,o);
    }
  }

  Object? visitPrintStmt_Quqstion(PrintStmt_Quqstion n, [Object? o]){
    var opt = n.getExpressionOpt();
    if(opt != null){
      visit(opt,o);
    }

  }

  Object? visitOnOffOption_on(OnOffOption_on n, [Object? o]){

  }

  Object? visitOnOffOption_off(OnOffOption_off n, [Object? o]){

  }

  Object? visitAutoResponseStmt(AutoResponseStmt n, [Object? o]){

  }

  Object? visitWriteFifoStmt_Identifier(WriteFifoStmt_Identifier n, [Object? o]){

  }

  Object? visitWriteFifoStmt_MacroName(WriteFifoStmt_MacroName n, [Object? o]){
    visit(n.getVariable(),o);
  }

  Object? visitUploadStmt_upload(UploadStmt_upload n, [Object? o]){
    visit(n.getSTRING_LITERAL(),o);
  }

  Object? visitUploadStmt_upload2(UploadStmt_upload2 n, [Object? o]){
      visit(n.getSTRING_LITERAL(),o);
  }

  Object? visitResetStmt_reset(ResetStmt_reset n, [Object? o]){

  }

  Object? visitResetStmt_reset2(ResetStmt_reset2 n, [Object? o]){

  }

  Object? visitResetStmt_reset_cold(ResetStmt_reset_cold n, [Object? o]){

  }

  Object? visitResetStmt_reset2_cold(ResetStmt_reset2_cold n, [Object? o]){

  }


  Object? visitInstallStmt_install(InstallStmt_install n, [Object? o]){
    visit(n.getInstallParameterList(),o);
  }

  Object? visitInstallStmt_install_2(InstallStmt_install_2 n, [Object? o]){
      visit(n.getInstallParameterList(),o);
  }

  Object? visitParameterItem(ParameterItem n, [Object? o]){

  }

  Object? visitParameterItemList(ParameterItemList n, [Object? o]){
    for(var i =0 ; i < n.size();++i){
      visit(n.getElementAt(i),o);
    }
  }

  Object? visitJcopAuthStmt_jcop22_ext_auth(JcopAuthStmt_jcop22_ext_auth n, [Object? o]){
    visit(n.getUtilFunctionParameterList(),o);
  }

  Object? visitJcopAuthStmt_jcop22_ext_auth_kmc(JcopAuthStmt_jcop22_ext_auth_kmc n, [Object? o]){
    visit(n.getUtilFunctionParameterList(),o);
  }

  Object? visitJcopAuthStmt_jcop22_ext_auth_2(JcopAuthStmt_jcop22_ext_auth_2 n, [Object? o]){
    visit(n.getUtilFunctionParameterList(),o);
  }

  Object? visitJcopAuthStmt_jcop22_ext_auth_kmc_2(JcopAuthStmt_jcop22_ext_auth_kmc_2 n, [Object? o]){
    visit(n.getUtilFunctionParameterList(),o);
  }

  Object? visitJcopAuthStmt_jcop22_ext_auth_nonblock(JcopAuthStmt_jcop22_ext_auth_nonblock n, [Object? o]){
    visit(n.getUtilFunctionParameterList(),o);
  }

  Object? visitSelectStmt_select(SelectStmt_select n, [Object? o]){
    visit(n.getUtilFunctionParameterList(),o);
  }

  Object? visitSelectStmt_select_2(SelectStmt_select_2 n, [Object? o]){
    visit(n.getUtilFunctionParameterList(),o);
  }

  Object? visitDeleteStmt_delete(DeleteStmt_delete n, [Object? o]){
    visit(n.getUtilFunctionParameterList(),o);
  }

  Object? visitDeleteStmt_delete_2(DeleteStmt_delete_2 n, [Object? o]){
    visit(n.getUtilFunctionParameterList(),o);
  }

  Object? visitApdu2Stmt(Apdu2Stmt n, [Object? o]){
    visit(n.getApduDataList(),o);
  }

  Object? visitPromptStmt(PromptStmt n, [Object? o]){

  }

  Object? visitShowapduStmt(ShowapduStmt n, [Object? o]){

  }

  Object? visitDes_3des_mac_call(Des_3des_mac_call n, [Object? o]){
    visit(n.getArgumentList(),o);
  }

  Object? visitDes_3des_mac_Stmt(Des_3des_mac_Stmt n, [Object? o]){

  }

  Object? visitFull_3des_mac_call(Full_3des_mac_call n, [Object? o]){
    visit(n.getArgumentList(),o);
  }

  Object? visitFull_3des_mac_Stmt(Full_3des_mac_Stmt n, [Object? o]){
    visit(n.getApduDataList(),o);
  }

  Object? visitMac_auto_mac_Stmt(Mac_auto_mac_Stmt n, [Object? o]){
      visit(n.getApduDataList(),o);
  }

  Object? visitLineEndOpt(LineEndOpt n, [Object? o])
  {

  }

  Object? visitSuperlongStmtInOneLine(SuperlongStmtInOneLine n, [Object? o])
  {
     visit(n.getApduDataList(),o);
  }

  Object? visitSuperlongStmtInMutipleLines(SuperlongStmtInMutipleLines n, [Object? o])
  {
    visit(n.getMultipleLineApduDataList(),o);
  }

  Object? visitCompareStmt(CompareStmt n, [Object? o]){
    visit(n.getUtilFunctionParameterList(),o);
  }
  Object? visitSocket_messageStmt(Socket_messageStmt n, [Object? o]){
    visit(n.getUtilFunctionParameterList(),o);
  }
  Object? visitGenerateStmt(GenerateStmt n, [Object? o]){
     visit(n.getUtilFunctionParameterList(),o);
  }
  Object? visitSendtextStmt(SendtextStmt n, [Object? o]){
    visit(n.getExpression(),o);
  }
  Object? visitPushStmt(PushStmt n, [Object? o]){
        visit(n.getApduDataList(),o);
  }
  Object? visitGotoStmt(GotoStmt n, [Object? o]){

  }
  Object? visitEmptyStatement0(EmptyStatement0 n, [Object? o]){

  }
  Object? visitEmptyStatement1(EmptyStatement1 n, [Object? o]){

  }

  Object? visitLoadOption_load_script(LoadOption_load_script n, [Object? o]) {

  }
  Object? visitLoadOption_loadprofile(LoadOption_loadprofile n, [Object? o]) {

  }
  Object? visitLoadOption_run_script(LoadOption_run_script n, [Object? o]) {

  }
  Object? visitMac_auto_mac_option(Mac_auto_mac_option n, [Object? o]){

  }
  Object? visitMac_auto_mac_option2(Mac_auto_mac_option2 n, [Object? o]) {

  }

  Object? visitCallSignature(CallSignature n, [Object? o]) {
        var opt = n.getFunctionParameterListOpt();
        if(opt != null){
          visit(opt,o);
        }
  }

}